﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Home.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<%@ Import Namespace="XDeal.DAL.Entities" %>
<%@ Import Namespace="XDeal.Common.Constants" %>
<%@ Import Namespace="Utility" %>
<%@ Import Namespace="Utility.Enums" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <%Deal ob = (Deal)ViewData[ConstViewDataName.DealOB];
      double percent = ConvertManage.ConvertToDouble(ob.DiscountPercent_i, 0);
      double oldPrice = ConvertManage.ConvertToDouble(ob.OldPrice_db, 0);
      double newPrice = oldPrice * (100 - percent) / 100;
      int dealID = ob.ID_i;
      int totalOrder = ob.OrderDetails.Count();
      int divWidth = 0;
      int minOrder = ConvertManage.ConvertToInt(ob.MinimumOrder_i, 0);
      if (minOrder <= 0)
          divWidth = 175;
      else
          divWidth = (int)(175 / (double)minOrder * totalOrder);
      if (divWidth > 175)
          divWidth = 175;
      DealStatus dealStatus = DealStatus.Open;
      if (totalOrder >= ob.CurrentQuantity_i || ob.Status_i == ConvertManage.ConvertToInt(DealStatus.SoldOut, 1))
          dealStatus = DealStatus.SoldOut;
      if (ob.EndDate_dt <= DateTime.Now || ob.Status_i == ConvertManage.ConvertToInt(DealStatus.Expires, 2))
          dealStatus = DealStatus.Expires;
      DateTime endDate = ConvertManage.ConvertToDateTime(ob.EndDate_dt, DateTime.Now);
    %>
    <div id="divThongTinDeal">
        <%if (dealStatus == DealStatus.SoldOut)
          {
              TimeSpan SoldOut = ConvertManage.ConvertToDateTime(ob.SoldOutDate_dt, DateTime.Now) - ConvertManage.ConvertToDateTime(ob.StartDate_dt, DateTime.Now);
              int daySoldOut = SoldOut.Days;
              int hourSoldOut = SoldOut.Hours;
              int minuteSoldOut = SoldOut.Minutes;              
        %>
        <div class="divDealItem">
            <div class="divDealName">
                <div class="divSaleOff">
                    <span>
                        <%:percent%>%</span>
                </div>
                <div class="DivTitle">
                    <h2>
                        <%=ob.Name_s%>
                    </h2>
                </div>
            </div>
            <div class="clear">
            </div>
            <div class="divDealInfor">
                <div class="divLeft">
                    <div class="divPriceTag">
                        <div class="divSoldOut">
                        </div>
                    </div>
                    <div class="clear">
                    </div>
                    <div class="divSoldOutText">
                        Bạn đã lỡ cơ hội
                    </div>
                    <div class="clear">
                    </div>
                    <div class="divThoiGian">
                        <div class="div01">
                            <div class="divOldPrice">
                                <div class="text">
                                    Trị giá</div>
                                <span>
                                    <%:ConvertManage.ConvertToCurrency(oldPrice)%></span>
                            </div>
                            <div class="divSave">
                                <div class="text">
                                    Tiết kiệm</div>
                                <%:ConvertManage.ConvertToCurrency(oldPrice - newPrice)%>
                            </div>
                            <div class="clear">
                            </div>
                        </div>
                        <div class="line">
                        </div>
                        <div class="div02">
                            <div class="divCCountOrder">
                                <div class="divCountOrder">
                                    <span>
                                        <%=totalOrder%></span> người mua
                                </div>
                            </div>
                            <div class="divCProgress">
                                <div class="divProgress" style="width: 175px;">
                                </div>
                            </div>
                        </div>
                        <div class="minOrder">
                            Bạn đã lỡ cơ hội mua giá tốt</div>
                        <div class="line">
                        </div>
                        <div class="divDateTime">
                            <div class="divText">
                                Cháy hàng trong
                                <%:daySoldOut%>
                                ngày
                                <%:hourSoldOut %>
                                giờ
                                <%:minuteSoldOut %>
                                phút</div>
                            <div class="divDate">
                                <%: String.Format("{0:dd/MM/yyyy}",(DateTime)ob.SoldOutDate_dt)%></div>
                        </div>
                        <div class="clear">
                        </div>
                    </div>
                    <div class="clear">
                    </div>
                    <div class="divShare">
                        <div class="c">
                            <%string facebookURL = "http://www.facebook.com/sharer.php?u=http://xdeal.vn" + Url.Content("~/ThongTinDeal/" + ob.ID_i + "/" + ConvertManage.GetSHTMLName(ob.ShortName_s));
                              string twitterURL = "http://twitter.com/share?url=http://xdeal.vn" + Url.Content("~/ThongTinDeal/" + ob.ID_i + "/" + ConvertManage.GetSHTMLName(ob.ShortName_s));
                              string googleURL = "http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://xdeal.vn" + Url.Content("~/ThongTinDeal/" + ob.ID_i + "/" + ConvertManage.GetSHTMLName(ob.ShortName_s));
                            %>
                            <a target="_blank" class="fb" href="<%=facebookURL%>"></a><a target="_blank" class="tt"
                                href="<%=twitterURL%>"></a><a target="_blank" class="tt" href="<%=googleURL%>">
                            </a>
                            <div class="clear">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="divRight">
                    <div id="divSlideShow<%:dealID%>" class="divIMGSlideShow">
                        <div class="ws_images">
                            <%List<string> lstTooltip = new List<string>();%>
                            <%foreach (DealImage diOB in ob.DealImages)
                              {%>
                            <span>
                                <img src="<%= Url.Content("~/Content/upload/SlideShowImg/" + diOB.ImageURL_s)%>"
                                    alt="<%:diOB.ID_i%>" title="<%:diOB.ID_i%>" id="wows<%:diOB.ID_i%>" />
                            </span>
                            <%
                                  lstTooltip.Add("<a href='#wows" + diOB.ID_i + "' title='" + diOB.ID_i + "'>" + "<img src='" + Url.Content("~/Content/upload/tooltips/" + diOB.ImageURL_s) + "' alt= '" + diOB.ID_i + "' />" + diOB.ID_i + "</a>");
                              }%>
                        </div>
                        <div class="ws_bullets">
                            <div>
                                <%foreach (string tooltipOB in lstTooltip)
                                  {%>
                                <%=tooltipOB%>
                                <%}%>
                            </div>
                        </div>
                        <div class="ws_shadow">
                        </div>
                        <div class="divWaterMark">
                            Cháy hàng trong
                            <%:daySoldOut%>
                            ngày
                            <%:hourSoldOut %>
                            giờ
                            <%:minuteSoldOut %>
                            phút
                        </div>
                    </div>
                    <script type="text/javascript">
                        $(function () {
                            jQuery("#divSlideShow<%:dealID%>").wowSlider(opSlider);
                        });
                    </script>
                </div>
            </div>
            <div class="clear">
            </div>
            <div class="divDealDetail">
                <div class="divTitle">
                    <div>
                        Chi tiết về sản phẩm</div>
                </div>
                <div class="divContent">
                    <%=ob.Detail_s%>
                </div>
                <div class="divSummary">
                    <div class="divCountTime" style="float: left;">
                        <div class="divText">
                            Đã cháy hàng</div>
                        <div class="divDate">
                            <%: String.Format("{0:dd/MM/yyyy}",(DateTime)ob.SoldOutDate_dt)%></div>
                    </div>
                    <div class="divPrice">
                        <div class="divRootPrice">
                            <div class="divText">
                                Giá trị</div>
                            <div class="divValue divLineThrough">
                                <%:ConvertManage.ConvertToCurrency(oldPrice)%></div>
                        </div>
                        <div class="clear">
                        </div>
                        <div class="divSave">
                            <div class="divText">
                                Tiết kiệm</div>
                            <div class="divValue">
                                <%:ConvertManage.ConvertToCurrency(oldPrice - newPrice)%></div>
                        </div>
                    </div>
                    <div class="divRealValue">
                        <div>
                            <%:ConvertManage.ConvertToCurrency(newPrice)%></div>
                    </div>
                    <div class="divLost">
                        Bạn đã lỡ cơ hội
                    </div>
                    <div class="clear">
                    </div>
                </div>
            </div>
        </div>
        <%}
          if (dealStatus == DealStatus.Open)
          {%>
        <div class="divDealItem">
            <div class="divDealName">
                <div class="divSaleOff">
                    <span>
                        <%:percent%>%</span>
                </div>
                <div class="DivTitle">
                    <h2>
                        <%=ob.Name_s%>
                    </h2>
                </div>
            </div>
            <div class="clear">
            </div>
            <div class="divDealInfor">
                <div class="divLeft">
                    <div class="divPriceTag">
                        <div class="divPrice">
                            <div>
                                <%:ConvertManage.ConvertToCurrency(newPrice)%></div>
                        </div>
                    </div>
                    <div class="clear">
                    </div>
                    <div class="divBtnBuy">
                        <a class="btnMuaNgay" href="<%=Url.Content("~/dat-mua/" + dealID + "/" + ConvertManage.GetSHTMLName(ob.ShortName_s)) %>"
                            title="Mua Ngay"></a><a class="btnMuaTang" href="<%=Url.Content("~/dat-mua/" + dealID + "/" + ConvertManage.GetSHTMLName(ob.ShortName_s)) %>"
                                title="Mua làm quà tặng"></a>
                    </div>
                    <div class="clear">
                    </div>
                    <div class="divThoiGian">
                        <div class="div01">
                            <div class="divOldPrice">
                                <div class="text">
                                    Trị giá</div>
                                <span>
                                    <%:ConvertManage.ConvertToCurrency(oldPrice)%></span>
                            </div>
                            <div class="divSave">
                                <div class="text">
                                    Tiết kiệm</div>
                                <%:ConvertManage.ConvertToCurrency(oldPrice - newPrice)%>
                            </div>
                            <div class="clear">
                            </div>
                        </div>
                        <div class="line">
                        </div>
                        <div class="div02">
                            <div class="divCCountOrder">
                                <div class="divCountOrder">
                                    <span>
                                        <%=totalOrder%></span> người mua
                                </div>
                            </div>
                            <div class="divCProgress">
                                <div class="divProgress" style="width: <%:divWidth%>px;">
                                </div>
                            </div>
                        </div>
                        <div class="minOrder">
                            <%if (totalOrder >= minOrder)
                              {%>
                            Bạn vẫn còn mua được
                            <%}
                              else
                              {%>
                            Cần <b>
                                <%:minOrder - totalOrder%></b> người mua nữa để có giá tốt
                            <%}%></div>
                        <div class="line">
                        </div>
                        <script type="text/javascript">
                            var vMonth = <%:endDate.Month%>;
                            var vYear = <%:endDate.Year%>;
                            var vDay = <%:endDate.Day%>;
                            if(vMonth == 1)
                            {
                                vMonth = 12;
                                vYear--;
                            }
                            else
                                vMonth--;                                
                            var dateFuture<%:dealID%> = new Date(vYear, vMonth, vDay, 23, 59, 0);
                            function GetCount(ddate, iid) {

                                dateNow = new Date(); //grab current date
                                amount = ddate.getTime() - dateNow.getTime(); //calc milliseconds between dates
                                delete dateNow;

                                // if time is already past
                                if (amount > 0) {
                                    hours = 0; mins = 0; secs = 0; out = "";

                                    amount = Math.floor(amount / 1000); //kill the "milliseconds" so just secs

                                    hours = Math.floor(amount / 3600); //hours
                                    amount = amount % 3600;

                                    mins = Math.floor(amount / 60); //minutes
                                    amount = amount % 60;

                                    secs = Math.floor(amount); //seconds
                                    if (hours < 10)
                                        hours = "0" + hours;
                                    if (mins < 10)
                                        mins = "0" + mins;
                                    if (secs < 10)
                                        secs = "0" + secs;
                                    out += "<div class='h'>" + hours + "</div>";
                                    out += "<div class='m'>" + mins + "</div>";
                                    out += "<div class='s'>" + secs + "</div>";
                                    out = out.substr(0, out.length - 2);                                    
                                    document.getElementById(iid).innerHTML = out;

                                    setTimeout(function () { GetCount(ddate, iid) }, 1000);
                                }
                            }                            
                        </script>
                        <div id="divTimerCount<%:dealID%>" class="divTimer">
                        </div>
                        <div class="clear">
                        </div>
                    </div>
                    <div class="clear">
                    </div>
                    <div class="divShare">
                        <div class="c">
                            <%string facebookURL = "http://www.facebook.com/sharer.php?u=http://xdeal.vn" + Url.Content("~/ThongTinDeal/" + ob.ID_i + "/" + ConvertManage.GetSHTMLName(ob.ShortName_s));
                              string twitterURL = "http://twitter.com/share?url=http://xdeal.vn" + Url.Content("~/ThongTinDeal/" + ob.ID_i + "/" + ConvertManage.GetSHTMLName(ob.ShortName_s));
                              string googleURL = "http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://xdeal.vn" + Url.Content("~/ThongTinDeal/" + ob.ID_i + "/" + ConvertManage.GetSHTMLName(ob.ShortName_s));
                            %>
                            <a target="_blank" class="fb" href="<%=facebookURL%>"></a><a target="_blank" class="tt"
                                href="<%=twitterURL%>"></a><a target="_blank" class="tt" href="<%=googleURL%>">
                            </a>
                            <div class="clear">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="divRight">
                    <div id="divSlideShow<%:dealID%>" class="divIMGSlideShow">
                        <div class="ws_images">
                            <%List<string> lstTooltip = new List<string>();%>
                            <%foreach (DealImage diOB in ob.DealImages)
                              {%>
                            <span>
                                <img src="<%= Url.Content("~/Content/upload/SlideShowImg/" + diOB.ImageURL_s)%>"
                                    alt="<%:diOB.ID_i%>" title="<%:diOB.ID_i%>" id="wows<%:diOB.ID_i%>" />
                            </span>
                            <%
                                  lstTooltip.Add("<a href='#wows" + diOB.ID_i + "' title='" + diOB.ID_i + "'>" + "<img src='" + Url.Content("~/Content/upload/tooltips/" + diOB.ImageURL_s) + "' alt= '" + diOB.ID_i + "' />" + diOB.ID_i + "</a>");
                              }%>
                        </div>
                        <div class="ws_bullets">
                            <div>
                                <%foreach (string tooltipOB in lstTooltip)
                                  {%>
                                <%=tooltipOB%>
                                <%}%>
                            </div>
                        </div>
                        <div class="ws_shadow">
                        </div>
                    </div>
                    <script type="text/javascript">
                        $(function () {
                            jQuery("#divSlideShow<%:dealID%>").wowSlider(opSlider);
                        });
                    </script>
                </div>
            </div>
            <div class="clear">
            </div>
            <div class="divDealDetail">
                <div class="divTitle">
                    <div>
                        Chi tiết về sản phẩm</div>
                </div>
                <div class="divContent">
                    <%=ob.Detail_s%>
                </div>
                <div class="divSummary">
                    <div class="divCountTime">
                        <div class="divTime" id="divTimerCount<%:dealID%>1">
                        </div>
                        <script type="text/javascript">
                            $(function () {
                                GetCount(dateFuture<%:dealID%>, 'divTimerCount<%:dealID%>');
                                GetCount(dateFuture<%:dealID%>, 'divTimerCount<%:dealID%>1');
                            });
                        </script>
                    </div>
                    <div class="divPrice">
                        <div class="divRootPrice">
                            <div class="divText">
                                Giá trị</div>
                            <div class="divValue divLineThrough">
                                <%:ConvertManage.ConvertToCurrency(oldPrice)%></div>
                        </div>
                        <div class="clear">
                        </div>
                        <div class="divSave">
                            <div class="divText">
                                Tiết kiệm</div>
                            <div class="divValue">
                                <%:ConvertManage.ConvertToCurrency(oldPrice - newPrice)%></div>
                        </div>
                    </div>
                    <div class="divRealValue">
                        <div>
                            <%:ConvertManage.ConvertToCurrency(newPrice)%></div>
                    </div>
                    <div class="divButton">
                        <a href="<%=Url.Content("~/dat-mua/" + dealID + "/" + ConvertManage.GetSHTMLName(ob.ShortName_s)) %>"
                            title="Mua Ngay"></a>
                    </div>
                    <div class="clear">
                    </div>
                </div>
            </div>
        </div>
        <%}
          if (dealStatus == DealStatus.Expires)
          {
        %>
        <div class="divDealItem">
            <div class="divDealName">
                <div class="divSaleOff">
                    <span>
                        <%:percent%>%</span>
                </div>
                <div class="DivTitle">
                    <h2>
                        <%=ob.Name_s%>
                    </h2>
                </div>
            </div>
            <div class="clear">
            </div>
            <div class="divDealInfor">
                <div class="divLeft">
                    <div class="divPriceTag">
                        <div class="divExpires">
                        </div>
                    </div>
                    <div class="clear">
                    </div>
                    <div class="divSoldOutText">
                        Bạn đã lỡ cơ hội
                    </div>
                    <div class="clear">
                    </div>
                    <div class="divThoiGian">
                        <div class="div01">
                            <div class="divOldPrice">
                                <div class="text">
                                    Trị giá</div>
                                <span>
                                    <%:ConvertManage.ConvertToCurrency(oldPrice)%></span>
                            </div>
                            <div class="divSave">
                                <div class="text">
                                    Tiết kiệm</div>
                                <%:ConvertManage.ConvertToCurrency(oldPrice - newPrice)%>
                            </div>
                            <div class="clear">
                            </div>
                        </div>
                        <div class="line">
                        </div>
                        <div class="div02">
                            <div class="divCCountOrder">
                                <div class="divCountOrder">
                                    <span>
                                        <%=totalOrder%></span> người mua
                                </div>
                            </div>
                            <div class="divCProgress">
                                <div class="divProgress" style="width: <%:divWidth%>px;">
                                </div>
                            </div>
                        </div>
                        <div class="minOrder">
                            Bạn đã lỡ cơ hội mua giá tốt</div>
                        <div class="line">
                        </div>
                        <div class="divDateTime">
                            <div class="divText">
                                Hết hạn từ:
                            </div>
                            <div class="divDate">
                                <%: String.Format("{0:dd/MM/yyyy}",(DateTime)ob.SoldOutDate_dt)%></div>
                        </div>
                        <div class="clear">
                        </div>
                    </div>
                    <div class="clear">
                    </div>
                    <div class="divShare">
                        <div class="c">
                            <%string facebookURL = "http://www.facebook.com/sharer.php?u=http://xdeal.vn" + Url.Content("~/ThongTinDeal/" + ob.ID_i + "/" + ConvertManage.GetSHTMLName(ob.ShortName_s));
                              string twitterURL = "http://twitter.com/share?url=http://xdeal.vn" + Url.Content("~/ThongTinDeal/" + ob.ID_i + "/" + ConvertManage.GetSHTMLName(ob.ShortName_s));
                              string googleURL = "http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://xdeal.vn" + Url.Content("~/ThongTinDeal/" + ob.ID_i + "/" + ConvertManage.GetSHTMLName(ob.ShortName_s));
                            %>
                            <a target="_blank" class="fb" href="<%=facebookURL%>"></a><a target="_blank" class="tt"
                                href="<%=twitterURL%>"></a><a target="_blank" class="tt" href="<%=googleURL%>">
                            </a>
                            <div class="clear">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="divRight">
                    <div id="divSlideShow<%:dealID%>" class="divIMGSlideShow">
                        <div class="ws_images">
                            <%List<string> lstTooltip = new List<string>();%>
                            <%foreach (DealImage diOB in ob.DealImages)
                              {%>
                            <span>
                                <img src="<%= Url.Content("~/Content/upload/SlideShowImg/" + diOB.ImageURL_s)%>"
                                    alt="<%:diOB.ID_i%>" title="<%:diOB.ID_i%>" id="wows<%:diOB.ID_i%>" />
                            </span>
                            <%
                                  lstTooltip.Add("<a href='#wows" + diOB.ID_i + "' title='" + diOB.ID_i + "'>" + "<img src='" + Url.Content("~/Content/upload/tooltips/" + diOB.ImageURL_s) + "' alt= '" + diOB.ID_i + "' />" + diOB.ID_i + "</a>");
                              }%>
                        </div>
                        <div class="ws_bullets">
                            <div>
                                <%foreach (string tooltipOB in lstTooltip)
                                  {%>
                                <%=tooltipOB%>
                                <%}%>
                            </div>
                        </div>
                        <div class="ws_shadow">
                        </div>
                        <div class="divWaterMark">
                            ĐÃ HẾT HẠN
                        </div>
                    </div>
                    <script type="text/javascript">
                        $(function () {
                            jQuery("#divSlideShow<%:dealID%>").wowSlider(opSlider);
                        });
                    </script>
                </div>
            </div>
            <div class="clear">
            </div>
            <div class="divDealDetail">
                <div class="divTitle">
                    <div>
                        Chi tiết về sản phẩm</div>
                </div>
                <div class="divContent">
                    <%=ob.Detail_s%>
                </div>
                <div class="divSummary">
                    <div class="divCountTime" style="float: left;">
                        <div class="divText">
                            Đã hết hạn</div>
                        <div class="divDate">
                            <%: String.Format("{0:dd/MM/yyyy}",(DateTime)ob.SoldOutDate_dt)%></div>
                    </div>
                    <div class="divPrice">
                        <div class="divRootPrice">
                            <div class="divText">
                                Giá trị</div>
                            <div class="divValue divLineThrough">
                                <%:ConvertManage.ConvertToCurrency(oldPrice)%></div>
                        </div>
                        <div class="clear">
                        </div>
                        <div class="divSave">
                            <div class="divText">
                                Tiết kiệm</div>
                            <div class="divValue">
                                <%:ConvertManage.ConvertToCurrency(oldPrice - newPrice)%></div>
                        </div>
                    </div>
                    <div class="divRealValue">
                        <div>
                            <%:ConvertManage.ConvertToCurrency(newPrice)%></div>
                    </div>
                    <div class="divLost">
                        Bạn đã lỡ cơ hội
                    </div>
                    <div class="clear">
                    </div>
                </div>
            </div>
        </div>
        <%}%>
    </div>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="HeaderContent" runat="server">
    <link href="<%= Url.Content("~/Content/DefaultTheme/css/HotDeal.css")%>" rel="stylesheet"
        type="text/css" />
    <link href="<%= Url.Content("~/Content/DefaultTheme/css/DealDetail.css")%>" rel="stylesheet"
        type="text/css" />
    <script src="<%= Url.Content("~/Content/js/Commons/JSFrontEndMenu.js")%>" type="text/javascript"></script>
    <script src="<%= Url.Content("~/Content/js/DealDetail/JsDealDetail.js")%>" type="text/javascript"></script>
    <link href="<%= Url.Content("~/Content/js/Tools/WowSlider/WowStyle.css")%>" rel="stylesheet"
        type="text/css" />
    <style type="text/css">
        a#vlb
        {
            display: none;
        }
    </style>
    <script src="<%= Url.Content("~/Content/js/Tools/WowSlider/wowslider.js")%>" type="text/javascript"></script>
    <script src="<%= Url.Content("~/Content/js/Tools/WowSlider/wowscript.js")%>" type="text/javascript"></script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="RightContent" runat="server">
</asp:Content>
